package com.ocl.www.config;

import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;

/**
 * 
 * @ClassName: SolrConfiguration
 * @Description: Solr Config
 * @author: xlh
 * @date: 2016年7月28日
 */
@Configuration
@EnableSolrRepositories(basePackages = "com.ocl.www.repositories", multicoreSupport = true)
public class SolrConfiguration {

	@Autowired
	private Environment environment;
	
	//solr应用
    public static final String SERVER = "core1";
	@Bean
	public HttpSolrClient solrClient() {
		System.out.println("solr.............");
		HttpSolrClient solrClient = new HttpSolrClient.Builder(environment.getRequiredProperty("spring.data.solr.host")+"/"+SERVER).build();
		solrClient.setConnectionTimeout(9000);
		return solrClient;	
	}


//	@Bean
//	public SolrServerFactory solrServerFactory() {
//		return new MulticoreSolrServerFactory(solrClient());
//	}
//
//	
//
//	@Bean
//	public SolrOperations solrTemplate() {
//		return new SolrTemplate(solrClient());
//	}

}
